<template>
    <div>
        <!--<Row type="flex" justify="start">
            <Col span="3">
                <Button type="default" long @click="backAction">返回列表</Button>
            </Col>
        </Row>-->
        <Alert>
            <span>请选择时间段后查询景区统计信息</span>
        </Alert>
        <Divider/>
        <br>
        <Row type="flex" justify="center">
            <Col span="12">
                <Form inline>
                    <FormItem>
                        <DatePicker v-model="statsTime" type="datetimerange"
                                    format="yyyy-MM-dd HH:mm" placeholder="请选择统计时间段"
                                    style="width: 350px"></DatePicker>
                    </FormItem>
                    <FormItem>
                        <Button :loading="btnLoading" type="success" @click="submitAction">查询</Button>
                    </FormItem>
                </Form>
            </Col>
        </Row>
        <Modal :title="'温馨提示'" v-model="modalShow" :width="400" :mask-closable="false" :closable="false">
            <div class="modal-content">操作成功，请重新登录！</div>
            <div slot="footer">
                <Button long type="default" @click="modalSubmit">确定</Button>
            </div>
        </Modal>
    </div>
</template>

<script>
import { getDayAllNum } from '@/api/pass'
import { formatDate } from '@/components/dateFormat'
export default {
  data () {
    return {
      btnLoading: false,
      modalShow: false,
      statsTime: ''
    }
  },
  methods: {
    backAction () {
      // if (this.$route.query) {
      this.$router.push({ name: 'recordList' })
      // }
    },
    submitAction () {
      const startTime = this.statsTime[0] !== '' ? formatDate(this.statsTime[0], 'yyyy-MM-dd hh:mm:ss') : ''
      const endTime = this.statsTime[1] !== '' ? formatDate(this.statsTime[1], 'yyyy-MM-dd hh:mm:ss') : ''
      if (startTime !== '' && endTime !== '') {
        this.btnLoading = true
        const param = {
          starttime: startTime,
          endtime: endTime
        }
        getDayAllNum(param).then(res => {
          if (res.data.errcode === 0) {
            this.btnLoading = false
            this.modalShow = true
          } else {
            this.btnLoading = false
            this.$Message.error(res.data.errmsg)
          }
        })
      } else {
        this.$Message.error('请选择统计时间段')
      }
    },
    modalSubmit () {
    }
  },
  mounted () {
  }
}
</script>

<style scoped>
    .modal-content {
        padding: 20px 10px 5px;
        text-align: center;
        font-size: 18px;
        font-weight: 600;
        color: #de0000;
    }
</style>
